//var calendar = new datePicker();
//var html = " ";
//var html1 = " ";
//var arr;
//calendar.init({
//	'trigger': '#demo1',
//	/*按钮选择器，用于触发弹出插件*/
//	'type': 'date',
//	/*模式：date日期；datetime日期时间；time时间；ym年月；*/
//	'minDate': '1900-1-1',
//	/*最小日期*/
//	'maxDate': '2020-12-31',
//	/*最大日期*/
//	'onSubmit': function() { /*确认时触发事件*/
//		var theSelectData = calendar.value;
//		console.log(calendar.value);
//		var age = jsGetAge(theSelectData);
//		console.log(age);
//		arr = age[0];
//		html = "<tr align='center'>" +
//			"<td>" + age[0] + "<br />年</td>" +
//			"<td>" + age[1] + "<br />月</td>" +
//			"<td>" + age[2] + "<br />周</td></tr>" +
//			"<tr align='center'><td>" +
//			age[3] + "<br />天</td><td>" +
//			age[4] + "<br />小时</td>" +
//			"<td><span class='td_min'>" +
//			age[5] + "</span><br>分钟</td>" + "</tr>";
//
//		$('.table_time').append(html);
//		$('.time_table').removeClass('none');
//		$('#demo1').css("display", "none");
//		$('.content_p').css("display", "none");
//		$('.btn11').removeClass('none');
//		html1 = age[0] + '.<span class="second">' + age[6] + '</span>';
//		$('.age_span').append(html1);
//		//				$('.die_btn').addClass('display1');
//		setInterval('changeTime()', 2000);
//
//	},
//	'onClose': function() { /*取消时触发事件*/ }
//});
var count = 0;

function changeTime() {
	count++;
	var start = $('.second').text()
	var a = $('.second').text();
	a++;
	a++;
	a++;
	a++;
	a++;

	$('.second').text(a);
	if(count % 60 == 0) {
		var td_min = $('.td_min').text();
		td_min++;

		$('.td_min').text(td_min);
	}
}

$('.die_btn').click(function() {
	$('.content').addClass('none');
	$('.die').removeClass('none');
})

//死亡页面
var biliHour, biliMin;

function dieCount(data, arr) {
	var remainWeek;
	var remainHoliday;
	var bili = (arr / data) * 1440;
	var b = [];
	var allLife = data;
	var remainLife = data - arr;
	var remainLove;
	var foods = remainLife * 1095;

	//
	biliHour = Math.floor(bili % 60);
	if(biliHour>24)
	{
		biliHour=biliHour%24;
	}
	biliMin = Math.floor(bili / 60 % 60);
	log('biliHour :' + biliHour + " biliHour" + biliMin);
	//
	log("foods " + foods);
	if(arr>data){
		
	b[0] = 0;
	b[1] = 0;
	b[2] = 0;
	b[3] = 0;
		
		
	}else {
		
	
	if(arr > 20) {
		if(data>50){
			data-50
			remainLove = (remainLife-(data-45))  * 100;

		}else{
			remainLove = remainLife  * 100;
		}
		
	} else if(arr <= 20) {
		remainLove = (remainLife - (20 - arr)) * 100;
		if(remainLove<0)
		{
			remainLove=0;
		}

	}

	remainWeek = remainLife * 52;
	remainHoliday = remainLife * 2;

	b[0] = foods;
	b[1] = remainLove;
	b[2] = remainWeek;
	b[3] = remainHoliday;
	}
	return b;
}

$('.live_btn').click(function() {
	$('.die').addClass('none');
	$('.live').removeClass('none');
})

$(function() {
	// ---------【数据部分开始】---------
	// 出生年份计算，当前年份-(当前年份-100)
	var nowYear = new Date().getFullYear();
	var gYear = [];

	for(var i = 0; i < 100; i++) {
		gYear.push(i);
	};
	// 身高范围，50-220
	// 年份
	$.scrEvent({
		data: gYear,
		evEle: '.qu-year',
		title: '选择死亡年龄',
		defValue: 70,
		afterAction: function(data) {
			$('.table_die').delegate(diehtml);
			var diehtml = '';
			var brr = dieCount(data, arr);
			$('.table_die')
			diehtml = "<tr align='center'>" +
				"<td>吃" + brr[0] + "顿饭</td>" +

				"<td>做" + brr[1] + "次爱</td></tr>" +
				"<tr align='center'><td>度过" +
				brr[2] + "个周末</td>" +

				"<td>享受" +
				brr[3] + "个长假</td>" + "</tr>";;

			$('.table_die').append(diehtml);
			$('.disappear').addClass('display1');
			$('.p1').addClass('p_none');
			$('.p2').removeClass('p_none');
			$('.p3').removeClass('p_none');
			$('.live_btn').addClass('display1');
			$('.selectAge_btn').addClass('display2');

			var html33 = biliHour + '点' + biliMin + "分";
			$('.now_time').append(html33);

		}
	});

	$.dateSelector({
		evEle: '.sp-time',
		startYear: '1950',
		endYear: '2017',
		timeBoo: false,
		afterAction: function(d1, d2, d3) {
			$('.sp-time').val(d1 + '-' + d2 + '-' + d3);
			
	
		var age = jsGetAge(d1,d2,d3);
		console.log(age);
		arr = age[0];
		html = "<tr align='center'>" +
			"<td>" + age[0] + "<br />年</td>" +
			"<td>" + age[1] + "<br />月</td>" +
			"<td>" + age[2] + "<br />周</td></tr>" +
			"<tr align='center'><td>" +
			age[3] + "<br />天</td><td>" +
			age[4] + "<br />小时</td>" +
			"<td><span class='td_min'>" +
			age[5] + "</span><br>分钟</td>" + "</tr>";

		$('.table_time').append(html);
		$('.time_table').removeClass('none');
		$('#selectDate_btn').css("display", "none");
		$('.content_p').css("display", "none");
		$('.btn11').removeClass('none');
		html1 = age[0] + '.<span class="second">' + age[6] + '</span>';
		$('.age_span').append(html1);
		//				$('.die_btn').addClass('display1');
		setInterval('changeTime()', 2000);
			
			
			
			
			
			
			
			
		}
	});

});